Technical Field
This disclosure relates generally to computer memory, and, more specifically, to handling memory page faults.
Description of the Related Art
Modern computer systems typically implement a virtual memory system in which primary storage (i.e., main memory) such as random access memory (RAM) is used as a cache for secondary storage such as hard disk drives, optical drives, etc. To process a request to access a particular memory location, a memory management unit (MMU) may receive a virtual memory address of the memory location and translate the virtual address to a corresponding physical address in memory. The MMU may then reference the physical address to retrieve the desired data.
Mappings for virtual addresses to physical addresses are typically stored in a data structure called a page table. A mapping may be inserted when an operating system loads a set of data (called a page) from secondary storage into primary storage. In some instances, a page fault may occur when an MMU is unable to determine the physical address for a given virtual address because the page table does not include a mapping for that address, the mapping is no longer valid, etc.
A central processor unit (CPU) may handle a page fault by invoking the operating system to retrieve the requested data from secondary storage. Since servicing a page fault (e.g., retrieving the data from secondary storage, writing it into primary storage, inserting a corresponding mapping into the page table, etc.) can take a significant amount of time, a CPU typically performs a context switch in which the CPU stops execution of the process that created the page fault and begins executing other processes. The CPU may resume execution of the initial process after the operating system has serviced the page fault.
Page faults can be problematic for a graphics processor unit (GPU) because it typically cannot perform a context switch from rendering a display to some other task, and thus ends up stalling. Any stall can easily be visible to the user. As a result, many GPUs do not support usage of virtual memory or require that all needed pages be loaded prior to performing any rendering to prevent potential page faults from occurring.